package com.totalinlink.dsl.poi

import com.totalinlink.dsl.poi.constants.StyleWrapper

/**
 * Created by wangguangyu on 15/5/24.
 */
class TestSupport {
    static void main(args) {
        def workbook = new WorkBookBuilder()
        def lst = []
        lst << []
        lst << ["人员信息", "", "", ""]
        lst << ["姓名", "年龄", "性别", "城市"]
        lst << ["张三", "30", "男", "北京"]
        lst << ["李四", "31", "女", "上海"]
        lst << ["王五", "32", "男", "广州"]
        lst << ["赵六", "33", "女", "深圳"]

        workbook (filename: "/Users/wangguangyu/temp/sample.xlsx") {
            font (
                    name: "first font",
                    italic: true,
                    bold: true,
                    strikeout: true,
                    underline: StyleWrapper.u_double,
                    boldweight: StyleWrapper.boldweight_bold,
                    fontName: "宋体 (正文)"
            )
            cellStyle (
                    name: "first style",
                    align: StyleWrapper.center,
                    verticalAlign: StyleWrapper.vertical_top,
                    //// align -> [center|left|right]
                    //// verticalAlign -> [vertical_top|vertical_bottom|vertical_center]
                    border: [bottom: StyleWrapper.border_thin,
                             top: StyleWrapper.border_thin,
                             left: StyleWrapper.border_thin,
                             right: StyleWrapper.border_thin
                    ],  //// each of values -> [double|thin|medium|dash|hair|thick]
                    borderColor: [bottom: StyleWrapper.black,
                            top: StyleWrapper.black,
                            left: StyleWrapper.black,
                            right: StyleWrapper.black
                    ],  //// each of values -> color set
                    font: "first font"
            )
            sheet (name: "人员信息", printSetup: [
                    pageStart: 0,
                    paperSize: StyleWrapper.a4_plus_papersize
            ], printArea: [
                    startColumn: 0,
                    endColumn: 1,
                    startRow: 0,
                    endRow: 1
            ]) {
                mergedRegion (range: [1, 1, 2, 5])
                rows(data: lst, withStyle: "first style", startIndex: 2)
                // forStyle (pos: [0, 10], style: "first style")
            }
        }

        workbook.save()
    }
}
